package com.yuncheng.mcp.controller;

import com.yuncheng.mcp.dto.ChatRequest;
import com.yuncheng.mcp.service.AiChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @title: ChatController
 * @Author: Liuxk
 * @Date: 2025/5/22 14:07
 */

@RestController
@RequestMapping("/api/chat")
public class ChatController {

    @Autowired
    private AiChatService aiChatService;

    /**
     * 处理聊天请求，使用AI和MCP工具进行响应
     *
     * @param request 聊天请求
     * @return 包含AI回复的响应
     */
    @PostMapping
    public String chat(@RequestBody ChatRequest request) {
        String message = request.getMessage();
        return aiChatService.ask(message);
    }

}
